package com.yesep.learn.mqtt.client.handler;

import com.yesep.learn.mqtt.client.common.event.EventManager;
import com.yesep.learn.mqtt.client.common.event.MqttEvent;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

/**
 * 
 * @Description:
 */
public class EventHandler extends ChannelInboundHandlerAdapter {

	@Override
	@SuppressWarnings("unckecked")
	public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
		if (evt instanceof MqttEvent) {
			MqttEvent event = (MqttEvent) evt;
			EventManager.notify(event.getKey(), event.getMessage());
		}
	}
}
